package com.hxy.spring.service.impl;

import com.hxy.spring.bean.Dept;
import com.hxy.spring.mapper.DeptMapper;
import com.hxy.spring.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DeptServiceImpl implements DeptService {
    @Autowired
    DeptMapper deptMapper;
    public List<Dept> findAllDept() {
        return deptMapper.selectByExample(null);
    }

    public  int insert(Dept dept) {
        return deptMapper.insertSelective(dept);
    }

    public Dept findDeptById(Integer id) {
        return deptMapper.selectByPrimaryKey(id);
    }

    public void updateDept(Dept dept) {
        deptMapper.updateByPrimaryKeySelective(dept);
    }

    public void deleteDept(Integer id) {
        deptMapper.deleteByPrimaryKey(id);

    }
}